package com.apt.action;

import java.io.File;

import org.apache.commons.io.FileUtils;

import com.apt.common.AptException;
import com.apt.facade.DataStoreHelper;
import com.apt.load.LoadUsers;

public class LoadUsersAction extends AptBaseAction {

	private File upload;
	private String uploadContentType;
	private String uploadFileName;
	private Integer selectedCollege;
	private Integer selectedDepartment;
	
	

	public Integer getSelectedCollege() {
		return selectedCollege;
	}

	public void setSelectedCollege(Integer selectedCollege) {
		this.selectedCollege = selectedCollege;
	}

	public Integer getSelectedDepartment() {
		return selectedDepartment;
	}

	public void setSelectedDepartment(Integer selectedDepartment) {
		this.selectedDepartment = selectedDepartment;
	}

	public String loadUsersData() {
		try{
			/*System.out.println("filename - " + getUploadFileName());
			System.out.println("file - " + getUpload());
			System.out.println("college - "+getSelectedCollege());
			System.out.println("dept - "+getSelectedDepartment());*/
			
			int roleId = DataStoreHelper.getRoleId("STUDENT");
			String [] departmentDetails = DataStoreHelper.getDepartmentName(selectedDepartment);
						
			LoadUsers lu = new LoadUsers();
			lu.readExcel(upload, roleId, departmentDetails, selectedCollege);
		}catch (AptException ex) {
			addActionError(ex.getMessage());
			return "error";

		}
		
		
		return SUCCESS;
	}

	public File getUpload() {
		return upload;
	}

	public void setUpload(File upload) {
		this.upload = upload;
	}

	public String getUploadContentType() {
		return uploadContentType;
	}

	public void setUploadContentType(String uploadContentType) {
		this.uploadContentType = uploadContentType;
	}

	public String getUploadFileName() {
		return uploadFileName;
	}

	public void setUploadFileName(String uploadFileName) {
		this.uploadFileName = uploadFileName;
	}

	

}
